package cn.cheln.support.highlight;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class KeyMatcher
{
  private static boolean isFuzzy;
  private static boolean isRegex = false;
  private Pattern enPattern;
  private int end;
  private boolean isMatchAlpha;
  Pattern pattern;
  private int start;
  private Pattern zhPattern;

  static
  {
    isFuzzy = false;
  }

  public KeyMatcher()
  {
    this.enPattern = null;
  }

  public KeyMatcher(String paramString)
  {
    this.enPattern = toRegex(paramString, true);
    this.zhPattern = toRegex(paramString, false);
  }

  private static Pattern toRegex(String paramString, boolean paramBoolean)
  {
    if ((isRegex) || (paramString.startsWith("re:")))
    {
      if (paramString.startsWith("re:"));
      for (String str1 = paramString.substring(3, paramString.length()); (!(paramBoolean)) && (!(str1.startsWith("^"))); str1 = paramString)
        return Pattern.compile("^" + str1, 2);
      return Pattern.compile(str1, 2);
    }
    String str2 = paramString.replace("\\", "\\u005C").replace(".", "\\u002E").replace("$", "\\u0024").replace("^", "\\u005E").replace("{", "\\u007B").replace("[", "\\u005B").replace("(", "\\u0028").replace(")", "\\u0029").replace("+", "\\u002B").replace("*", "[\\s\\S]*").replace("?", "[\\s\\S]");
    if (paramBoolean)
      return Pattern.compile(str2, 2);
    return Pattern.compile("^" + str2, 2);
  }

  public int getEnd()
  {
    return this.end;
  }

  public int getStart()
  {
    return this.start;
  }

  public boolean isMatchAlpha()
  {
    return this.isMatchAlpha;
  }

  public boolean match(String paramString1, String paramString2, boolean paramBoolean)
  {
    if (match(paramString1, paramBoolean));
    do
      return true;
    while (match(paramString2, paramBoolean));
    return false;
  }

  public boolean match(String paramString, boolean paramBoolean)
  {
    if (paramBoolean);
    for (Pattern localPattern = this.enPattern; ; localPattern = this.zhPattern)
    {
      this.pattern = localPattern;
      Matcher localMatcher = this.pattern.matcher(paramString);
      if (!(localMatcher.find()))
        break;
      this.start = localMatcher.start();
      this.end = localMatcher.end();
      return true;
    }
    return false;
  }

  public void matcherClean()
  {
    this.start = 0;
    this.end = 0;
  }

  public void setEnd(int paramInt)
  {
    this.end = paramInt;
  }

  public void setMatchAlpha(boolean paramBoolean)
  {
    this.isMatchAlpha = paramBoolean;
  }

  public void setStart(int paramInt)
  {
    this.start = paramInt;
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     cn.cheln.support.highlight.KeyMatcher
 * JD-Core Version:    0.5.2
 */